﻿/**
 * @file FuTcpServer.h
 * @author tjc
 * @brief TCP发送和接收模块
 * @version 1.0
 * @date 2024-3-4
 */

#ifndef TCPSERVER_H
#define TCPSERVER_H
#include <QObject>
#include <QTcpServer>
#include <QTcpSocket>
#include <QMessageBox>
//设计成单例对象
class FuTcpServer : public QObject
{
    Q_OBJECT
private:
    explicit FuTcpServer(QObject *parent = nullptr);
    static FuTcpServer *fuTcpServer;
public:
    //智能家居服务端 ip
    QString ip= "192.168.1.226";
    //智能家居服务端 port
    int port = 8080;
    //智能家居发送的指令
    int command;
    QTcpSocket *socket = nullptr;
    QTcpServer *server = nullptr;
    //获取本对象的函数
    static FuTcpServer* getTcpServer();
    //初始化智能家居服务端
    void initServer();
signals:
    //连接状态改变
    void signal_connect(bool);
    //读取到数据
    void signal_readData();
public slots:
    //创建连接的槽函数
    void slot_newConnection();
    //关闭连接的槽函数
    void slot_closeConnection();
};
#endif // FUTCPSERVER_H
